package beans;

import me.dqn.annotation.Subscriber;

import java.util.Random;

/**
 * @author dqn
 * created at 2018/8/3 - 16:57
 */
public class MySubscriber {
    private String name;

    public MySubscriber(String name) {
        this.name = name;
    }

    @Subscriber
    public void subscribeA(AEvent aEvent) {
        try {
            Thread.sleep(Math.abs(new Random().nextLong() % 2000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("from " + name + " " + aEvent.getaMsg() + Thread.currentThread());
    }

    @Subscriber
    public void subscribeB(BEvent bEvent) {
        try {
            Thread.sleep(Math.abs(new Random().nextLong() % 2000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(bEvent.getbMsg() + Thread.currentThread());
    }
}
